#include<bits/stdc++.h>
using namespace std;

int main() {
	int g,basic,workout,over ;
	char rj ; // rush judge
	cin >>g>>rj ;
	if (g<=1000)
	{
		workout = 8;
	}
	else 
	{
		over = g-1000 ;
		
		if (over < 500 ) 
		{
			workout = 12;		
		} 
		else
		{
			workout = over/500*4+8 ;
		}
		

	}
	
	if (rj == 'y')
	{
		workout = workout+5 ;
	}

	return 0;
}

